<template>
  <fragment>
    <CRM ref="crm" :call-tel="callTel" :call-id="callid" :record-id="recordId" @relevance="crmRelevanceHandle"></CRM>
    <TelRecord ref="telRcrd" dep="sale" :call-tel="callTel" :call-id="callid" :record-id="recordId"></TelRecord>
    <!-- B2C电商订单记录-->
    <!-- <OrderRecord ref="orderRcrd" online :call-tel="callTel" :call-id="callid" :record-id="recordId" @relevance="relevanceHandle"></OrderRecord> -->
    <!-- ECO电商订单记录-->
    <!-- <OrderRecord ref="orderRcrdECO" online eco :call-tel="callTel" :call-id="callid" :record-id="recordId" @relevance="relevanceHandle"></OrderRecord> -->
    <!-- <OrderRecord ref="orderReatilRcrd" :call-tel="callTel" :call-id="callid" :record-id="recordId" @relevance="relevanceHandle"></OrderRecord> -->
    <CallReg :order-data="orderData" :crm-data="crmData" v-bind="$props" @refresh="$emit('refresh', 'save')"></CallReg>
  </fragment>
</template>
<script>
import TelRecord from './TelRecord'
// import OrderRecord from './OrderRecord'
import CallReg from './CallReg'
import CRM from './CRM'
import { deepCopy } from '@/utils'
export default {
  name: 'Sale',
  components: {
    TelRecord,
    // OrderRecord,
    CallReg,
    CRM
  },
  props: {
    callTel: {
      type: String,
      default: ''
    },
    callid: {
      type: String,
      default: ''
    },
    recordId: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      orderData: {},
      crmData: {}
    }
  },
  methods: {
    // 订单关联
    relevanceHandle(row, online, eco) {
      const d = deepCopy(row)
      if (!online) {
        delete d.storeName
        if (this.$refs.orderRcrd) this.$refs.orderRcrd && this.$refs.orderRcrd.clearRelevance()
        if (this.$refs.orderRcrdECO) this.$refs.orderRcrdECO && this.$refs.orderRcrdECO.clearRelevance()
      } else {
        if (eco) this.$refs.orderRcrd && this.$refs.orderRcrd.clearRelevance()
        else this.$refs.orderRcrdECO && this.$refs.orderRcrdECO.clearRelevance()

        this.$refs.orderReatilRcrd && this.$refs.orderReatilRcrd.clearRelevance()
      }
      this.orderData = d
    },
    // crm关联
    crmRelevanceHandle(row) {
      this.crmData = row
    }
  }
}
</script>

